﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Algorithm.Phan1.BaiToanLietKe._2.PhuongPhapSinh
{
    class SinhDayNhiPhanDoDaiN
    {
        public SinhDayNhiPhanDoDaiN()
        {
            DoIt();
        }

        private void DoIt() 
        {
            var path = Directory.GetCurrentDirectory().ToString();
            path = path.Replace(@"bin\Debug","")+@"Phan1.BaiToanLietKe\2.PhuongPhapSinh\";
            var inputpath = path+ "input.txt";
            var outputpath = path + "output.txt";
            var max = 100;

            var x = new int[max];
            int n;
            n = Convert.ToInt32(File.ReadAllText(inputpath));
            int k = n;
            var f = new StringBuilder();
            string tempstr = "";
            //Set all value of array is 0
            for (int j = 0; j < max; j++)
            {
                x[j] = 0;
            }

            while (k >= 0)
            {
                for (int i = 0; i < n; i++)
                {
                    f.Append(x[i].ToString());
                }
                f.AppendLine();
                k = n - 1;//phan tu cuoi cung cua mang
                while (k>-1 && x[k]==1) //Lui den gia tri x[k]==0
                {
                    k--;
                }
                if (k>-1)
                {
                    x[k] = 1;
                    for (int l = k + 1; l < n; l++)
                    {
                        x[l] = 0;
                    }    
                }
            }
            Console.WriteLine(f.ToString());
            File.WriteAllText(outputpath,f.ToString());
            //Console.WriteLine(File.ReadAllText(path));

                   
        }
    }
}
